﻿namespace RestaurantMenu.Library
{
    public class Food : Product
    {
        // fields
        private FoodType type;
        private int prepareTime;

        // constructors
        public Food(FoodType menuTypes, string foodName, int prepareTime, decimal price, int weight)
            :base(foodName,price,weight)
        {
            this.Type = menuTypes;
            this.PrepareTime = prepareTime;
        }

        public Food(FoodType menuTypes, string foodName, int prepareTime, NutritionFacts nutrition, decimal price, int weight)
            : this(menuTypes, foodName, prepareTime, price, weight)
        {
            this.Nutrition = nutrition;
        }

        // properties
        public FoodType Type
        {
            get
            {
                return this.type;
            }

            private set
            {
                this.type = value;
            }
        }

        public int PrepareTime
        {
            get
            {
                return this.prepareTime;
            }

            private set
            {
                if ((value < 0) || (value > 30))
                {
                    throw new InvalidRangeException<int>(string.Format("The prepare time should be in range [{0}..{1}]!", 0, 30), 0, 30);
                }

                this.prepareTime = value;
            }
        }

        // methods
        public override string ToString()
        {
            return string.Format("Food Name : {0,-30} | Price : {1,8:C2}| Weight : {2,3} gr", this.Name, this.Price, this.Weight);
        }
    }
}
